#发送邮件
import yagmail
mail_address = "18794762984@163.com"
mail_host = "smtp.163.com"
mail_port = 465
mail_password = "152378Wsa@123"
# def sendmail(to_user: list,
#              subject:str,
#              text:str,
#              att=None):
#     if isinstance(to_user,(str,list)) and isinstance(subject,str) and isinstance(text,str):
#         #初始化邮件服务器对象
#         smtp=yagmail.SMTP(user=mail_address,
#                      password=mail_password,
#                      host=mail_host,
#                      port=mail_port,
#                      smtp_ssl=True)
#         smtp.send(to=to_user,subject=subject,contents=text,attachments=att)
#     else:
#         raise TypeError("参数类型错误")
# data="""
# 一条大运河，半部华夏史。今年是中国大运河申遗成功十周年。6月23日，“何以中国·运载千秋”网络主题采访活动从扬州出发，探寻大运河作为文化根脉、生态绿脉、经济动脉所散发的独特魅力。
# """
# sendmail(to_user=mail_address,subject="python实训",text=data)
def sendmail(to_user: list, 
             subject: str, 
             text: str, 
             att=None):
    if isinstance(to_user, (str, list)) and isinstance(subject, str) and isinstance(text, str):
        ## 初始化邮件服务器对 象
        smtp = yagmail.SMTP(user=mail_address,
                     password=mail_password,
                     host=mail_host,
                     port=mail_port,
                     smtp_ssl=True)
        smtp.send(to=to_user, subject=subject, contents=text, attachments=att)
    else:
        raise TypeError("参数类型错误")
data = '''
亲爱的吃瓜群众们，最近娱乐圈又热闹起来了，话题的中心人物不是别人，正是那位从不让我们失望的热议大王——王思聪，俗话说男人的生活不能太寂寞，看来这位总裁又开启了他的“狗粮慈善模式”。这不，最近他和现任懒懒情侣装亮相人前，甜蜜度爆表，把爱意大方洒向了日本街头，甜蜜的样子让无数单身狗情何以堪！
'''
sendmail(to_user=mail_address, subject="python实训", text=data)